package net.posick.ws.soap;

import java.io.Serializable;

import net.posick.ws.xml.Name;
import net.posick.ws.xml.Namespace;
import net.posick.ws.xml.XmlElement;

public class SOAPAction extends SOAPBase implements Serializable
{
    private static final long serialVersionUID = 201403271221L;
    
    
    public static final String ELEMENT_NAME = "Action";
    
    public static final Name FQN = new Name(new Namespace(PREFIX_SOAP_ADDRESSING, NAMESPACE_SOAP_ADDRESSING), ELEMENT_NAME);
    
    public static final String HTTP_HEADER_NAME = "SOAPAction";
    
    
    public SOAPAction()
    {
        super(FQN);
    }
    
    
    public SOAPAction(String action)
    {
        super(FQN);
        setValue(action);
    }


    public static SOAPAction toSOAPAction(XmlElement element)
    throws SOAPException
    {
        SOAPAction action;
        
        if (FQN.equals(element.getName()))
        {
            action = new SOAPAction();
            action.copyFrom(element);
        } else
        {
            throw new SOAPException("\"" + element.getName() + "\" is NOT a SOAPAction element.");
        }
        
        return action;
    }
}
